module('lgx.decls.ctor', package.seeall)
local decl = require'lgx.decl'
local func = require'lgx.decls.func'

local mt = func.new()
mt.__index = mt

function new(o)
    o = func.new(o)
    o.tag = decl.CTOR
    setmetatable(o,mt)
    return o
end

function mt:iscopyctor()
    if #self.args ~= 1 then
        return false
    end
    local ctxinfo = self:ctx():typeinfo()
    local arginfo = self:typeinfo(self.args[1].type)
    if ctxinfo.decl ~= arginfo.decl then
        return false
    end
    return arginfo.cvtype and arginfo.rtype and (not arginfo.ptype)
end
